#ifndef DATETIMEPICKER_H
#define DATETIMEPICKER_H

#include <QWidget>
#include <QListWidget>
#include <QListWidgetItem>
#include "QDateTime"
#include "QListWidget"
#include "QScrollBar"
#include "blldataflow.h"
#include <QDebug>
#include "shadow.h"
#include <QPaintEvent>
#include <QPainter>
#include "project.h"

namespace Ui {
class DateTimePicker;
}

enum DateTimeType {
    All = 63,
    Date = 56,
    Time = 7,
    Year = 32,
    Month = 16,
    Day = 8,
    Hour = 4,
    Minute = 2,
    Second = 1
};

class DateTimePicker : public QWidget
{
    Q_OBJECT

public:
    explicit DateTimePicker(QWidget *parent = nullptr, int type = DateTimeType::All, QString whatsThis = "datetimepicker", QDateTime dateTime = QDateTime::currentDateTime());
    ~DateTimePicker();

signals:

private slots:
    void on_btnNow_clicked();
    void on_btnConfirm_clicked();
    void on_btnClose_clicked();

    void on_monthBox_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
    void on_yearBox_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);

    void turnPageSlot();

    void setWidgetParent();
    void retranslateUiSlot();

private:
    void init(int type, QDateTime dt);
    void updateUi();

protected:
    void paintEvent(QPaintEvent *);

public:
    void setDateTime(QDate d);
    void setDateTime(QTime t);
    void setDateTime(QDateTime dt);

private:
    Ui::DateTimePicker *ui;
    BllDataFlow *bdf;
    QDateTime dateTime;
    int dateTimeType;
    int year;
    int month;
    int day;
    int hour;
    int minute;
    int second;
    const int itemHeight = 40;
};

#endif // DATETIMEPICKER_H
